package main

import (
	"flag"
	"fmt"
	"goProxy/tool"
)

func main() {

	var host string
	var port int
	var upstreamProxy string
	var upstreamAuth string

	flag.StringVar(&host, "u", "0.0.0.0", "host")
	flag.IntVar(&port, "p", 9000, "port")
	flag.StringVar(&upstreamProxy, "up", "usa.rotating.proxyrack.net:11111", "ip:port")
	flag.StringVar(&upstreamAuth, "ua", "unfflcc:76cc14-47b8dd-1f8ace-827836-0c740e", "name:password")
	flag.Parse() //转换，必须调用
	fmt.Printf("host=%v\nport=%v\nupstreamProxy=%v\nupstreamProxy=%v\n", host, port, upstreamProxy, upstreamAuth)
	var upstream *tool.UpstreamProxy
	if upstreamProxy != "" {
		upstream = tool.NewUpstreamProxy(upstreamProxy, upstreamAuth)
	}
	s := tool.NewServer(fmt.Sprintf("%s:%d", host, port), upstream)
	s.Start()

}
